From 1176172d848fdb4f33a3099ee1ac1975ddcd686a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 18 Dec 2023 06:17:09 -0700 Subject: [PATCH] modernize google maps javascript (#1247) to avoid: "js: Google Maps JavaScript API has been loaded directly without a callback. This is not supported and can lead to race conditions and suboptimal performance. For supported loading patterns please see https://goo.gle/js-api-loading" --- gui/gmapbase.html | 56 +++++++++++++++++++++++++++++++++++------------ gui/map.cc | 3 +-- gui/map.h | 5 +++++ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/gui/gmapbase.html b/gui/gmapbase.html index 15a50f8be..71422331a 100644 --- a/gui/gmapbase.html +++ b/gui/gmapbase.html @@ -3,8 +3,14 @@ Google Maps JavaScript - - + diff --git a/gui/map.cc b/gui/map.cc index 228959f21..e6e82fa60 100644 --- a/gui/map.cc +++ b/gui/map.cc @@ -76,8 +76,6 @@ Map::Map(QWidget* parent, stopWatch_.start(); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); manager_ = new QNetworkAccessManager(this); - connect(this,&QWebEngineView::loadFinished, - this,&Map::loadFinishedX); this->logTime("Start map constructor"); auto* mclicker = new MarkerClicker(this); @@ -85,6 +83,7 @@ Map::Map(QWidget* parent, this->page()->setWebChannel(channel); // Note: A current limitation is that objects must be registered before any client is initialized. channel->registerObject(QStringLiteral("mclicker"), mclicker); + connect(mclicker, &MarkerClicker::loadFinished, this, &Map::loadFinishedX); connect(mclicker, &MarkerClicker::markerClicked, this, &Map::markerClicked); connect(mclicker, &MarkerClicker::logTime, this, &Map::logTime); diff --git a/gui/map.h b/gui/map.h index 1ea743aab..6c2e69b7a 100644 --- a/gui/map.h +++ b/gui/map.h @@ -60,10 +60,15 @@ public slots: { emit logTime(s); } + void loadedX() + { + emit loadFinished(true); + } signals: void markerClicked(int t, int i); void logTime(const QString& s); + void loadFinished(bool b); }; -- 2.30.2